VHDL development setup
Introduction
This is just describing the steps to setup my VHDL development and simulation enviroment. I'll be using will be VS code as my IDE, emacs as my styler and GHDL as my simulator and error checker. GHDL seems to be constantly in flux as Tristan Gingold is a powerhouse of the opensource community. These steps may not work.
IDE setup
After building and installing the ghdl vscode extension: Put the code below in a file anywhere. I prefer /usr/bin/vf
#!/bin/sh
for i in '$@'
do
emacs -batch $i --eval '(vhdl-beautify-buffer)' -f save-buffer
rm $i~
#echo $i >> /home/twoninefour/gay.txt
done
Install the vscode extension emeraldwalk.runonsave, add the code below to settings.json either for your project or for global vscode settings
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.vhdl$",
"isAsync": false,
"cmd": "vf ${file}"
}
]
}
Each project needs a file name hdl-prj.json in its main directory. The format is below
{
"options": {
"ghdl_analysis": [
]
},
"files": [
{ "file": "src/pwm_tb.vhdl", "language": "vhdl" },
{ "file": "src/pwm.vhdl", "language": "vhdl" },
{ "file": "src/heartbeat.vhdl", "language": "vhdl" },
{ "file": "src/freqcomb.vhdl", "language": "vhdl" },
{ "file": "src/freqgen.vhdl", "language": "vhdl" }
]
}
To use GHDL you need to analyze every file with ghdl -a filename first. Then elaborate on your top level one with ghdl -e module_name and then run the executable generated with various parameters. A sample Makefile is below
default: pwm
pwm:
ghdl -m pwm_tb
ghdl -e pwm_tb
./pwm_tb --stop-time=5ms --wave=wave.ghw
graph: pwm
gtkwave wave.ghw